package cate.game.play.buff.h;

import cate.common.util.XT;
import cate.game.play.buff.Buff;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;

/**
 * 提升10%pk减伤并有50%概率免疫1次负面状态
 */
public class 乾天罡气BH extends BuffHandler {

	private int 概率;

	private int 次数;

	//概率=5000&次数=1
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		次数 = args.getInt("次数", 0);
	}

	private int num;

	@Override
	public boolean allowAddBuff(ActionCtx action, Buff buffToAdd) {
		if (num >= 次数) {
			return true;
		}
		if (buffToAdd.isGood()) {
			return true;
		}
		if (!XT.chance(概率)) {
			return true;
		}
		num++;
		return false;
	}
}
